<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
        <link rel="stylesheet" href="../book.css" charset="ISO-8859-1" type="text/css"/>
        <title>Tane - Hide Delegate - Usage</title>
    </head>
    <body>
    	<h1>Hide Delegate - Usage</h1>
    	<p>Given the code at the start of the above example, select the code to be refactored in the Java editor:</p>
    	
    	<div class="code"><pre>
Foo foo = new Foo();
&#8230;
foo.<span class="selected">getBar().getBaz().doSomething()</span>;
    	</pre></div>
    	
    	<p>Note that you can select any part of the sequence of invocations. You could, for example, have selected just
    		<span class="code">getBar().getBaz()</span> or <span class="code">getBaz().doSomething()</span>.</p>
    	<p>Now either:</p>
    	<ul>
    		<li>invoke <b>Quick Assist</b> and select <b>Hide Delegate</b>, or</li>
    		<li>bring up the <b>context sensitive menu</b> and select the <b>Hide Delegate...</b> menu item (note that this menu item is <i>not</i>
    			under the <b>Refactor</b> sub-menu because we <a href="http://dev.eclipse.org/newslists/news.eclipse.tools.jdt/msg22831.html"
    			title="Question on the news.eclipse.tools.jdt newsgroup about adding to the refactoring menu">don't know how</a> to get that
    			to happen).</li>
    		</ul>
    	<p>The refactoring wizard that appears will check that appropriate <a href="preconditions.html" title="Hide Delegate Preconditions">
    		preconditions</a> have been met and then ask for some information:</li>
    	<ul>
    		<li>A name for the new method.</li>
    		<li>The scope for replacement. This refactoring will search the selected scope for the same method invocation sequence that was
    			selected and replace it with a call to the new method. This is a powerful way of replacing significant amounts of code with a
    			better alternative, particularly if the code exhibits symptoms of 'procedural' thinking.</li>
    	</ul>
    	<p>After entering the appropriate information, click 'Next'. The refactoring will work out what needs to be done and then show you a
    		preview of the work to be done, as usual. If you are happy with the changes, click 'Finish' and the changes will be applied.</p>
    	<p>When launching using <b>Quick Assist</b> you can simply put the cursor at the beginning of the delegate to be hidden. This will
    		have the same effect as if you had selected the entire sequence of invocations from the cursor onwards.</p>
       	<hr/>
    	<div class="attribution">
    		This plugin is provided by <a href="http://www.stateofflow.com" title="State Of Flow homepage">State Of Flow</a>
    	</div>
    </body>
</html>